package com.itheima.mall.service.smsService;

import com.itheima.pojo.sms.SmsHomeAdvertise;
import com.itheima.mall.commons.PageResult;
import com.itheima.mall.commons.R;
import com.itheima.mall.service.smsService.SmsHomeAdvertiseServiceApi;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SmsHomeAdvertiseService {
    @DubboReference
    private SmsHomeAdvertiseServiceApi smsHomeAdvertiseServiceApi;
    /**
     * 添加广告
     * advertise
     */
    public R create(SmsHomeAdvertise advertise) {
        smsHomeAdvertiseServiceApi.create(advertise);
        return R.ok("操作成功!");
    }
    /**
     * 删除广告  ids
     */
    public R delete(List<Long> ids) {
        smsHomeAdvertiseServiceApi.delete(ids);
        return R.ok("操作成功!");
    }

    /**
     * 分页查询广告
     * endTime name pageNum pageSize type
     */
    public R list(String endTime, String name, Integer pageNum, Integer pageSize, Integer type) {
        PageResult<SmsHomeAdvertise> res = smsHomeAdvertiseServiceApi.list(endTime,name,type, pageNum, pageSize);
        return R.ok(res);
    }
    /**
     * 修改上下线状态
     * id status
     */
    public R updateStatus(Long id, Integer status) {
        smsHomeAdvertiseServiceApi.updateStatus(id,status);
        return R.ok("操作成功!");
    }

    /**
     * 修改广告
     * id smsHomeAdvertise
     */
    public R updateById(Long id, SmsHomeAdvertise smsHomeAdvertise) {
        smsHomeAdvertiseServiceApi.updateById(id,smsHomeAdvertise);
        return R.ok("操作成功!");
    }

    /**
     * 获取广告详情
     * id
     */
    public R getAdvertiseById(Long id) {
        SmsHomeAdvertise smsHomeAdvertise = smsHomeAdvertiseServiceApi.getAdvertiseById(id);
        return R.ok(smsHomeAdvertise);
    }
}
